home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / system-tools-backends-2.0 / scripts / UsersConfig.pm < prev   
Encoding:
Perl POD Document  |  2007-03-12  |  2.6 KB  |  84 lines

  1. #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  
  3. # DBus object for the Users list
  4. #
  5. # Copyright (C) 2005 Carlos Garnacho
  6. #
  7. # Authors: Carlos Garnacho Parro  <carlosg@gnome.org>
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU Library General Public License as published
  11. # by the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. # GNU Library General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Library General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  22.  
  23. package UsersConfig;
  24.  
  25. use base qw(StbObject);
  26. use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX);
  27. use Users::Users;
  28. use Users::Shells;
  29.  
  30. my $OBJECT_NAME = "UsersConfig";
  31. my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME";
  32. my $format = [[ "array", [ "struct", "uint32", "string", "string", "int32", "int32", [ "array", "string"], "string", "string" ]],
  33.               ["array", "string" ], "int32", "int32", "int32", "string", "string", "int32" ];
  34.  
  35. sub new
  36. {
  37.   my $class = shift;
  38.   my $self  = $class->SUPER::new ($OBJECT_PATH, $OBJECT_NAME);
  39.  
  40.   bless $self, $class;
  41.  
  42. #  Utils::Monitor::monitor_files (&Users::Users::get_files (),
  43. #                                 $self, $OBJECT_NAME, "changed");
  44.   return $self;
  45. }
  46.  
  47. dbus_method ("get", [], $format);
  48. dbus_method ("set", $format, []);
  49. #dbus_signal ("changed", []);
  50.  
  51. sub get
  52. {
  53.   my ($self) = @_;
  54.   my $logindefs, $users, $use_md5, $shells;
  55.   $self->SUPER::reset_counter ();
  56.  
  57.   $use_md5 = &Users::Users::get_use_md5 ();
  58.   $logindefs = &Users::Users::get_logindefs ();
  59.   $users = &Users::Users::get ();
  60.   $shells = &Users::Shells::get ();
  61.  
  62.   return ($users, $shells, $use_md5, $$logindefs{"umin"},
  63.           $$logindefs{"umax"}, $$logindefs{"home_prefix"},
  64.           $$logindefs{"shell"}, $$logindefs{"group"});
  65. }
  66.  
  67. sub set
  68. {
  69.   my ($self, @config) = @_;
  70.   $self->SUPER::reset_counter ();
  71.  
  72.   Users::Users::set ($config[0]);
  73.   Users::Shells::set ($config[1]);
  74.   Users::Users::set_logindefs ({"umin"        => $config[3],
  75.                                 "umax"        => $config[4],
  76.                                 "home_prefix" => $config[5],
  77.                                 "shell"       => $config[6],
  78.                                 "group"       => $config[7]});
  79. }
  80.  
  81. my $config = UsersConfig->new ();
  82.  
  83. 1;
  84.